﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using Yunwei.Domain.Models;

namespace Yunwei.Web.Areas.RRShop.Models
{
    public class FoodIngredientViewModel
    {
        public int Id { get; set; }
        
        [Required]
        [Display(Name="菜品")]
        public int Food_Id { get; set; }

        [Required]
        [Display(Name = "食材")]
        public int Ingredient_Id { get; set; }

        [Required]
        [Display(Name = "用量")]
        public decimal Amount { get; set; }

        [Required]
        [Display(Name = "餐馆")]
        public int Restaurant_Id { get; set; }

        public FoodIngredient FoodIngredient
        {
            get
            {
                FoodIngredient fi = new FoodIngredient()
                {
                    Amount = this.Amount,
                    Food_Id = this.Food_Id,
                    Id = this.Food_Id,
                    Ingredient_Id = this.Ingredient_Id
                };

                return fi;
            }
        }

        public static FoodIngredientViewModel FromFoodIngredient(FoodIngredient fi)
        {
            FoodIngredientViewModel fivm = new FoodIngredientViewModel()
            {
                Amount = fi.Amount,
                Food_Id = fi.Food_Id,
                Id = fi.Food_Id,
                Ingredient_Id = fi.Ingredient_Id
            };

            return fivm;
        }
    }
}